package tech.aistar.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tech.aistar.entity.EnvironmentFaclity;

import java.util.List;


public interface EnvironmentFacilityMapper {
    @Select("select * from environment_facility")
    List<EnvironmentFaclity> selectAll();

    @Insert("insert into environment_facility (house_id,greenery,traffic_convenient," +
            "shopping_convenient,school_nearby_house,fridge," +
            "television,washing_machine,geyser,air_condition," +
            "broadband,sofa,bed,heat,wardrobe,cookingable," +
            "bathroom,balcony,intelligent_lock,range_hood,gas_stove)" +
            " value(#{houseId},#{greenery},#{trafficConvenient},#{shoppingConvenient}" +
            ",#{schoolNearbyHouse},#{fridge},#{television},#{washingMachine},#{geyser},#{airCondition}," +
            "#{broadband},#{sofa},#{bed},#{heat},#{wardrobe},#{cookingable},#{bathroom},#{balcony}," +
            "#{intelligentLock},#{rangeHood},#{gasStove})")
    void insert(EnvironmentFaclity environmentFaclity);
    @Update("update  environment_facility set house_id=#{houseId},greenery=${greenery},traffic_convenient=${trafficConvenient}" +
            ",shopping_convenient=#{shoppingConvenient},school_nearby_house=#{schoolNearbyHouse},fridge=#{fridge}" +
            ",television=#{television},washing_machine=#{washingMachine},geyser=#{geyser}, " +
            "air_condition=#{airCondition},broadband=#{broadband}" +
            ",sofa=#{sofa},bed=#{bed},heat=#{heat},wardrobe=#{wardrobe},cookingable=#{cookingable}" +
            ",bathroom=#{bathroom},balcony=#{balcony},intelligent_lock=#{intelligentLock}" +
            ",range_hood=#{rangeHood},gas_stove=#{gasStove} where id=#{Id}")
    void  updateByPrimaryKey(EnvironmentFaclity environmentFaclity);

    @Delete("delete from environment_facility where id=#{Id}")
    void deleteByPrimaryKey(Integer id);

//    List<EnvironmentFaclity> EnvironmentFaclitySearch(
//            @Param("lab") String lab, @Param("min") String min, @Param("max") String max, @Param("type") String type, @Param("chao") String chao);

    @Select("select house_id from environment_facility where greenery=#{greenery} and traffic_convenient=#{trafficConvenient}" +
            " and shopping_convenient=#{shoppingConvenient} and school_nearby_house=#{schoolNearbyHouse} and fridge=#{fridge}" +
            " and television=#{television} and washing_machine=#{washingMachine} and geyser=#{geyser}" +
            " and air_condition=#{airCondition} and broadband=#{broadband}" +
            " and sofa=#{sofa} and bed=#{bed} and heat=#{heat} and wardrobe=#{wardrobe} and cookingable=#{cookingable}" +
            " and bathroom=#{bathroom} and balcony=#{balcony} and intelligent_lock=#{intelligentLock}" +
            " and range_hood=#{rangeHood} and gas_stove=#{gasStove}")
    List<Integer> selectByAll(EnvironmentFaclity environmentFaclity);

    @Select("select * from environment_facility where id=#{Id}")
    EnvironmentFaclity findById(Integer integer);

    @Select("select * from environment_facility where house_id=#{houseId}")
    EnvironmentFaclity findByhouseId(Integer integer);







}
